﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using EPiServer.Core.Html.StringParsing;

namespace OpenWaves.EPiServer.UnitTests
{
    public static class EPiServerInfrastructureStub
    {
        public class NullFragmentParser : IFragmentParser
        {
            public StringFragmentCollection Parse(string content, FragmentParserMode parserMode, bool evaluateHash)
            {
                return new StringFragmentCollection((IEnumerable<IStringFragment>) new[] { new StaticNullFragment(content) });
            }

            private class StaticNullFragment : IStringFragment
            {
                private readonly string value;

                public string InternalFormat
                {
                    get
                    {
                        return this.value;
                    }
                }

                public IList<Guid> ReferencedPermanentLinkIds
                {
                    get
                    {
                        return new List<Guid>();
                    }
                }

                public StaticNullFragment(string str)
                {
                    this.value = str;
                }

                public string GetEditFormat()
                {
                    return this.InternalFormat;
                }

                public string GetViewFormat()
                {
                    return this.InternalFormat;
                }

                public string GetOnPageEditFormat()
                {
                    return this.InternalFormat;
                }

                public Control GetControl(TemplateControl hostPage)
                {
                    return new Literal
                               {
                                   Text = this.InternalFormat
                               };
                }

                public void RemapPermanentLinkReferences(IDictionary<Guid, Guid> idMap)
                {
                }
            }
        }
    }
}